import argparse
import sys
import logging
from config.config import DEFAULT_DOWNLOAD_PATH
from utils.downloader import ModelDownloader

# 配置日志
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)

def parse_args():
    parser = argparse.ArgumentParser(description='ModelScope模型下载工具')
    parser.add_argument('--model_id', type=str, required=True,
                      help='ModelScope模型ID')
    parser.add_argument('--output_dir', type=str, default=DEFAULT_DOWNLOAD_PATH,
                      help=f'下载目录 (默认: {DEFAULT_DOWNLOAD_PATH})')
    return parser.parse_args()

def main():
    args = parse_args()
    
    try:
        downloader = ModelDownloader(args.output_dir)
        logger.info(f"开始下载模型: {args.model_id}")
        logger.info(f"下载目录: {args.output_dir}")
        
        model_path = downloader.download_model(args.model_id)
        logger.info(f"模型下载成功！保存在: {model_path}")
        
    except Exception as e:
        logger.error(f"下载失败: {str(e)}")
        sys.exit(1)

if __name__ == "__main__":
    main() 